package com.digitalchina.lxnsy.fragment;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.apkfuns.logutils.LogUtils;
import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.activity.ecardConsult.EcardConsultActivity;
import com.digitalchina.lxnsy.activity.farmTrain.MyDemandListActivity;
import com.digitalchina.lxnsy.activity.farmTrain.MyQuoteListActivity;
import com.digitalchina.lxnsy.activity.farmTrain.TrainMyCaseActivity;
import com.digitalchina.lxnsy.activity.farmTrain.TrainOrgUpdateActivity;
import com.digitalchina.lxnsy.activity.farmVideo.MyCommentActivity;
import com.digitalchina.lxnsy.activity.farmVideo.MyConcernActivity;
import com.digitalchina.lxnsy.activity.farmVideo.MyFansActivity;
import com.digitalchina.lxnsy.activity.farmVideo.MyPraiseListActivity;
import com.digitalchina.lxnsy.activity.farmVideo.MyPurchaseListActivity;
import com.digitalchina.lxnsy.activity.farmVideo.MyWorkManageActivity;
import com.digitalchina.lxnsy.activity.farmVideo.UpdateExpertActivity;
import com.digitalchina.lxnsy.activity.old.AboutUsActivity;
import com.digitalchina.lxnsy.activity.old.AccountExpertManagementActivity;
import com.digitalchina.lxnsy.activity.old.AccountPersonManagementActivity;
import com.digitalchina.lxnsy.activity.old.ActivityManagerListActivity;
import com.digitalchina.lxnsy.activity.old.AuditStateActivity;
import com.digitalchina.lxnsy.activity.old.HelpAndFeedbackActivity;
import com.digitalchina.lxnsy.activity.old.LoginGuideActivity;
import com.digitalchina.lxnsy.activity.old.MyAddressListActivity;
import com.digitalchina.lxnsy.activity.old.MyCollectActivity;
import com.digitalchina.lxnsy.activity.old.MyConsultListActivity;
import com.digitalchina.lxnsy.activity.old.MyEnterpriseActivity;
import com.digitalchina.lxnsy.activity.old.MyFarmListActivity;
import com.digitalchina.lxnsy.activity.old.MyFarmMoneyActivity;
import com.digitalchina.lxnsy.activity.old.MyOrderListActivity;
import com.digitalchina.lxnsy.activity.old.MyShareBuyOrderListActivity;
import com.digitalchina.lxnsy.activity.old.MyShareSellOrderListActivity;
import com.digitalchina.lxnsy.activity.old.MyWalletActivity;
import com.digitalchina.lxnsy.activity.old.PersonnelServiceListActivity;
import com.digitalchina.lxnsy.activity.old.ShareFarmManagerActivity;
import com.digitalchina.lxnsy.api.BusinessAccount;
import com.digitalchina.lxnsy.base.BaseV4Fragment;
import com.digitalchina.lxnsy.constant.Constant;
import com.digitalchina.lxnsy.constant.MSG;
import com.digitalchina.lxnsy.constant.URL;
import com.digitalchina.lxnsy.entity.ApkUpdateVO;
import com.digitalchina.lxnsy.entity.ExpertInfoVO;
import com.digitalchina.lxnsy.entity.MyInfo3VO;
import com.digitalchina.lxnsy.entity.PersonalInfoVO;
import com.digitalchina.lxnsy.toolkit.AppInfo;
import com.digitalchina.lxnsy.toolkit.CustomDialog;
import com.digitalchina.lxnsy.toolkit.FastJsonUtil;
import com.digitalchina.lxnsy.toolkit.FrescoUtil;
import com.digitalchina.lxnsy.toolkit.GotoUtil;
import com.digitalchina.lxnsy.toolkit.OkHttpUtil;
import com.digitalchina.lxnsy.toolkit.StringUtil;
import com.digitalchina.lxnsy.toolkit.Utils;
import com.digitalchina.lxnsy.update.UpdateApk;
import com.digitalchina.lxnsy.xml.ExpertInfoXML;
import com.digitalchina.lxnsy.xml.PersonalInfoXML;
import com.digitalchina.lxnsy.xml.UserXML;
import com.facebook.drawee.view.SimpleDraweeView;
import com.lzy.okhttputils.model.HttpParams;

import org.json.JSONException;
import org.json.JSONObject;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.fragment
 * 创建人：郑皓
 * 创建时间：2017/1/20 17:16
 * 修改备注：
 * ================================================
 */
public class MainPersonalV2Fragment extends BaseV4Fragment implements  Handler.Callback {

    @Bind(R.id.personal_info_sdv_header)
    SimpleDraweeView personalInfoSdvHeader;
    @Bind(R.id.personal_info_tv_name)
    TextView personalInfoTvName;
    @Bind(R.id.personal_info_iv_sex)
    ImageView personalInfoIvSex;
    @Bind(R.id.personal_info_tv_nick)
    TextView personalInfoTvNick;
    @Bind(R.id.personal_info_tv_login)
    TextView personalInfoTvLogin;
    @Bind(R.id.personal_info_ll_account_manager)
    LinearLayout personalInfoLlAccountManager;
    @Bind(R.id.personal_info_ll_audit)
    LinearLayout personalInfoLlAudit;  // 审核状态

    private static final int LOGIN_CODE = 1;
    private static final int ACCOUNT_MANAGER_CODE = 2;
    private static final int MSG_ACTION_CALLBACK = 3;
    @Bind(R.id.layout_hudong)
    LinearLayout layoutHudong;
    @Bind(R.id.tv_guanzhu)
    TextView tvGuanzhu;
    @Bind(R.id.tv_fensi)
    TextView tvFensi;
    @Bind(R.id.tv_huozan)
    TextView tvHuozan;
    @Bind(R.id.tv_shenhezhuangtai)
    TextView tvShenhezhuangtai;
    @Bind(R.id.layout_fufei_zhuajia)
    RelativeLayout layoutFufeiZhuajia;
    @Bind(R.id.tv_fufei_zhuanjia)
    TextView tvFufeiZhuanjia;
    @Bind(R.id.tv_zhuanjia_lv)
    TextView tvZhuanjiaLv;
    @Bind(R.id.tv_my_train)
    TextView tvMyTrain;
    @Bind(R.id.tv_train_baojia)
    TextView tvTrainBaojia;
    @Bind(R.id.tv_train_case)
    TextView tvTrainCase;

    private boolean mSubUserType = false;

    @Override
    public View setRootView() {
        return inflate(R.layout.fragment_main_personal_information_v2);
    }

    @Override
    public void initMember() {

//        showActionBar();
//        setTitle("我的");

//        showByLogin();
        showTipNum();

    }

    /**
     * 根据通知消息显示提示
     */
    private void showTipNum() {
        // 设置提示信息数
    }

    private void showByLogin() {


        if ("1".equals(UserXML.getLoginStatus(getActivity()))) {

            // 设置名称
            if (UserXML.getUserType(getActivity()).equals(Constant.USER_TYPE_EXPERT))
                personalInfoTvName.setText(ExpertInfoXML.getExpertName(getActivity()));
            else
                personalInfoTvName.setText(StringUtil.isStrEmpty(PersonalInfoXML.getTrueName(getActivity())) ? UserXML.getUseraccName(getActivity()) : PersonalInfoXML.getTrueName(getActivity()));

            // 第二行数据
            personalInfoTvNick.setText("邀请码：" + UserXML.getInviteCode(getActivity()));

            personalInfoTvName.setVisibility(View.VISIBLE);
            personalInfoTvNick.setVisibility(View.VISIBLE);
            personalInfoTvLogin.setVisibility(View.GONE);
            personalInfoIvSex.setVisibility(View.VISIBLE);
            // 显示账户管理
            personalInfoLlAccountManager.setVisibility(View.VISIBLE);
            // 设置头像
            String imagePath = PersonalInfoXML.getHeadportrait(getActivity());
            if (!TextUtils.isEmpty(imagePath)) {
                FrescoUtil.showImageSmall(imagePath, personalInfoSdvHeader);
            }

            // 设置性别
            if ("1".equals(PersonalInfoXML.getUserSex(getActivity()))) {
                personalInfoIvSex.setVisibility(View.VISIBLE);
                personalInfoIvSex.setImageResource(R.drawable.icon_sex_male);
            } else if ("0".equals(PersonalInfoXML.getUserSex(getActivity()))) {
                personalInfoIvSex.setImageResource(R.drawable.icon_sex_female);
                personalInfoIvSex.setVisibility(View.VISIBLE);
            } else {
                personalInfoIvSex.setVisibility(View.GONE);
            }

            //是否为专家
            if (UserXML.getUserType(getActivity()).equals(Constant.USER_TYPE_EXPERT)) {
                personalInfoLlAudit.setVisibility(View.VISIBLE);
                // 获取专家信息
                BusinessAccount.toEditPersonalInfo(getActivity(), mHandler);
                layoutHudong.setVisibility(View.VISIBLE);
                layoutFufeiZhuajia.setVisibility(View.VISIBLE);
            } else {
                personalInfoLlAudit.setVisibility(View.GONE);
                layoutHudong.setVisibility(View.GONE);
                layoutFufeiZhuajia.setVisibility(View.GONE);
                // 获取个人信息
                BusinessAccount.getPersonalInfoById(getActivity(), mHandler);
            }

            //获取粉丝关注，升级专家
            HttpParams params = new HttpParams();
            params.put("userAccId", UserXML.getUserId(getActivity()));

            OkHttpUtil.post(getActivity(), URL.URL_GET_MY_PERSON_VO, "", params, mHandler, MSG_S_0, MSG_F_0);
        } else {
            layoutHudong.setVisibility(View.GONE);
            personalInfoTvName.setVisibility(View.GONE);
            personalInfoLlAudit.setVisibility(View.GONE);
            personalInfoTvNick.setVisibility(View.GONE);
            personalInfoIvSex.setVisibility(View.GONE);
            personalInfoTvLogin.setVisibility(View.VISIBLE);
            personalInfoLlAccountManager.setVisibility(View.GONE);
            personalInfoSdvHeader.setImageResource(R.drawable.bg_default_head);
        }
    }

    @Override
    public void setHandler() {

        mHandler = new Handler() {
            @Override
            public void handleMessage(Message msg) {
                super.handleMessage(msg);
                if (getActivity() == null)
                    return;

                switch (msg.what) {
                    case MSG.MSG_GET_PERSONAL_INFO_BY_ID_SUCCESS: // 获取个人信息
                        callBack(msg.obj);
                        break;
                    case MSG.MSG_GET_PERSONAL_INFO_BY_ID_FIELD:
                        LogUtils.e(msg.obj);
                        break;
                    case MSG.MSG_TO_EDIT_PERSONAL_INFO_SUCCESS: // 专家信息
                        saveExpertInfo(msg.obj.toString());
                        break;
                    case MSG.MSG_TO_EDIT_PERSONAL_INFO_FIELD:
                        LogUtils.e(msg.obj);
                        break;
                    case MSG.MSG_APP_SHARE_SUCCESS: // app分享
                        LogUtils.e(msg.obj);
                        break;
                    case MSG.MSG_GET_APK_UPDATE_SUCCESS: // app获取版本信息
                        ApkUpdateVO vo = FastJsonUtil.getBean(msg.obj.toString(), ApkUpdateVO.class);
                        if (AppInfo.getVersionCode(getActivity()) < vo.getVersionCode())
                            UpdateApk.update();
                        else
                            CustomDialog.nativeDialog(getActivity(), "当前已经是最新版本");
                        break;
                    case MSG.MSG_GET_APK_UPDATE_FIELD: // app获取版本信息
                        showToast(msg.obj.toString());
                        break;
                    case MSG_S_0: // 我的信息
                        setMyInfo(msg.obj.toString());
                        break;
                }
            }
        };

    }

    //设置关注数量粉丝数量等
    private void setMyInfo(String json) {
        MyInfo3VO vo = FastJsonUtil.getBean(json, "", MyInfo3VO.class);
        if (vo != null) {
            if (vo.getData() != null) {
                if (vo.getData().getFollowNum() != null)
                    tvGuanzhu.setText("关注 " + vo.getData().getFollowNum());
                if (vo.getData().getFansNum() != null)
                    tvFensi.setText("粉丝 " + vo.getData().getFansNum());
                if (vo.getData().getGetPraiseNum() != null)
                    tvHuozan.setText("获赞 " + vo.getData().getGetPraiseNum());

                //是否为培训机构
                if ("TRAIN_ORG_TYPE".equals(vo.getData().getSubUserType())) {
                    callJsMethod("setItem",new String[]{"is-org","1"});
                    mSubUserType = true;
                    tvShenhezhuangtai.setText("企业信息");
                    personalInfoLlAudit.setVisibility(View.VISIBLE);
                    tvMyTrain.setVisibility(View.GONE);
                    tvTrainBaojia.setVisibility(View.VISIBLE);
                    tvTrainCase.setVisibility(View.VISIBLE);
                } else {
                    callJsMethod("setItem",new String[]{"is-org","0"});
                    mSubUserType = false;
                    tvMyTrain.setVisibility(View.VISIBLE);
                    tvTrainBaojia.setVisibility(View.GONE);
                    tvTrainCase.setVisibility(View.GONE);
                }

                if (vo.isIsExpert()) {
                    if (vo.getData().getAuditStatus() != null) {
                        switch (vo.getData().getAuditStatus()) {
                            case "0":
                                tvZhuanjiaLv.setText("立即升级");
                                tvZhuanjiaLv.setTextColor(Color.parseColor("#8f6822"));
                                break;
                            case "1":
                                tvZhuanjiaLv.setText("审核中");
                                tvZhuanjiaLv.setTextColor(Color.parseColor("#8f6822"));
                                break;
                            case "2":
                                tvZhuanjiaLv.setVisibility(View.GONE);
                                break;
                            case "3":
                                tvZhuanjiaLv.setText("审核失败");
                                tvZhuanjiaLv.setTextColor(Color.parseColor("#EB6563"));
                                break;
                        }
                    } else {
                        tvZhuanjiaLv.setText("立即升级");
                        tvZhuanjiaLv.setTextColor(Color.parseColor("#8f6822"));
                    }

                }
            }

            if (vo.isIsExpert()) {
                //付费专家
                if ("1".equals(vo.getConsultIsFee())) {
                    tvFufeiZhuanjia.setText("您已经是收费咨询专家");
                } else {
                    tvFufeiZhuanjia.setText("升级成为收费咨询专家");
                }
            }
        }

    }

    /**
     * 保存专家信息
     */
    private void saveExpertInfo(String json) {
        ExpertInfoVO expertInfoVO = FastJsonUtil.getBean(json, "expertInfo", ExpertInfoVO.class);

        if (expertInfoVO != null) {
            if (!StringUtil.isStrEmpty(expertInfoVO.getPhoto()))
                // 设置头像
                FrescoUtil.showImageSmall(expertInfoVO.getPhoto(), personalInfoSdvHeader);


            // 设置名称
            personalInfoTvName.setText(expertInfoVO.getExpertName());
            // 设置性别
            if ("男".equals(expertInfoVO.getExpertSex())) {
                personalInfoIvSex.setVisibility(View.VISIBLE);
                personalInfoIvSex.setImageResource(R.drawable.icon_sex_male);
                PersonalInfoXML.setUserSex(getActivity(), "1");
            } else if ("女".equals(expertInfoVO.getExpertSex())) {
                personalInfoIvSex.setVisibility(View.VISIBLE);
                personalInfoIvSex.setImageResource(R.drawable.icon_sex_female);
                PersonalInfoXML.setUserSex(getActivity(), "0");
            } else {
                personalInfoIvSex.setVisibility(View.GONE);
            }

            ExpertInfoXML.setExpertInfoVO(getActivity(), expertInfoVO);
        }
    }

    @Override
    public void callBack(Object object) {

        try {
            // 储存兴趣爱好ALL JSON 到XML
            String body = new JSONObject(object.toString()).getString("body");
            String hobby = new JSONObject(body).getString("allHobby");
            PersonalInfoXML.setAllHobbiesJson(getActivity(), hobby);
            // 储存个人信息
            savePersonalInfo(object.toString());
        } catch (JSONException e) {
            e.printStackTrace();
        }

    }

    /**
     * 储存个人信息到xml
     *
     * @param json
     */
    private void savePersonalInfo(String json) {

        // 个人信息
        PersonalInfoVO personalInfoVO = FastJsonUtil.getBean(json, "body", "personalInfo", PersonalInfoVO.class);
        if (personalInfoVO != null) {
            PersonalInfoXML.setPersonalInfoVO(getActivity(), personalInfoVO);

            // 设置头像
            FrescoUtil.showImageSmall(personalInfoVO.getHeadPortrait(), personalInfoSdvHeader);
            // 设置名称
            if (UserXML.getUserType(getActivity()).equals(Constant.USER_TYPE_EXPERT))
                personalInfoTvName.setText(ExpertInfoXML.getExpertName(getActivity()));
            else
                personalInfoTvName.setText(StringUtil.isStrEmpty(PersonalInfoXML.getTrueName(getActivity())) ? UserXML.getUseraccName(getActivity()) : PersonalInfoXML.getTrueName(getActivity()));
            // 设置性别
            if ("1".equals(personalInfoVO.getUserSex())) {
                personalInfoIvSex.setImageResource(R.drawable.icon_sex_male);
            } else {
                personalInfoIvSex.setImageResource(R.drawable.icon_sex_female);
            }
        }
    }


    @OnClick({R.id.layout_my_money, R.id.layout_my_coin, R.id.layout_my_collect, R.id.tv_mall, R.id.tv_sell, R.id.tv_buy, R.id.tv_share_manage, R.id.tv_address, R.id.tv_consult, R.id.tv_activity_manage, R.id.tv_my_farm,
            R.id.tv_nhb, R.id.tv_focus_company, R.id.personal_info_rl_help, R.id.personal_info_rl_share, R.id.personal_info_rl_about, R.id.personal_info_ll_account_manager, R.id.personal_info_tv_login, R.id.personal_info_ll_audit,
            R.id.personal_info_rl_update, R.id.tv_ecard_consult, R.id.tv_guanzhu, R.id.tv_fensi, R.id.tv_huozan, R.id.tv_zhuanjia_lv, R.id.tv_video_manage, R.id.tv_buy_video, R.id.tv_video_zan, R.id.tv_video_pinglun, R.id.tv_my_train,
            R.id.tv_train_baojia, R.id.tv_train_case})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.layout_my_money: // 我的钱包
                noLoginToSkip(MyWalletActivity.class);
                break;
            case R.id.layout_my_coin: // 我的农币
                noLoginToSkip(MyFarmMoneyActivity.class);
                break;
            case R.id.layout_my_collect: // 我的收藏
                noLoginToSkip(MyCollectActivity.class);
                break;
            case R.id.tv_mall: // 买卖订单
                noLoginToSkip(MyOrderListActivity.class);
                break;
            case R.id.tv_sell: // 我的销售订单
                noLoginToSkip(MyShareSellOrderListActivity.class);
                break;
            case R.id.tv_buy: // 我的购买订单
                noLoginToSkip(MyShareBuyOrderListActivity.class);
                break;
            case R.id.tv_share_manage: // 共享管理
                noLoginToSkip(ShareFarmManagerActivity.class);
                break;
            case R.id.tv_address: // 地址管理
                noLoginToSkip(MyAddressListActivity.class);
                break;
            case R.id.tv_consult: // 我的咨询
                noLoginToSkip(MyConsultListActivity.class);
                break;
            case R.id.tv_activity_manage: // 活动管理
                noLoginToSkip(ActivityManagerListActivity.class);
                break;
            case R.id.tv_my_farm: // 我的农场
                noLoginToSkip(MyFarmListActivity.class);
                break;
            case R.id.tv_nhb: // 我的农活帮
                if (!Utils.isLogin(getActivity()))
                    Utils.notLoginGoto(getActivity());
                else {
                    GotoUtil.gotoActivity(getActivity(), PersonnelServiceListActivity.class, "key", "mytalents");
                }
                break;
            case R.id.tv_focus_company: // 关注企业
                noLoginToSkip(MyEnterpriseActivity.class);
                break;
            case R.id.personal_info_rl_help:
                GotoUtil.gotoActivity(getActivity(), HelpAndFeedbackActivity.class);
                break;
            case R.id.personal_info_rl_share:
                break;
            case R.id.personal_info_rl_about: // 关于我们
                GotoUtil.gotoActivity(getActivity(), AboutUsActivity.class);
                break;
            case R.id.personal_info_ll_account_manager: // 账户管理
                if (UserXML.getUserType(getActivity()).equals(Constant.USER_TYPE_EXPERT))
                    startActivityForResult(new Intent(getActivity(), AccountExpertManagementActivity.class), ACCOUNT_MANAGER_CODE);
                else
                    startActivityForResult(new Intent(getActivity(), AccountPersonManagementActivity.class), ACCOUNT_MANAGER_CODE);
                break;
            case R.id.personal_info_tv_login: // 登录
                startActivityForResult(new Intent(getActivity(), LoginGuideActivity.class), LOGIN_CODE);
                break;
            case R.id.personal_info_ll_audit: // 审核状态
                if (mSubUserType) {
                    //机构信息管理
                    GotoUtil.gotoActivity(getActivity(), TrainOrgUpdateActivity.class);
                } else {
                    startActivityForResult(new Intent(getActivity(), AuditStateActivity.class), LOGIN_CODE);
                }
                break;
            case R.id.personal_info_rl_update: // 检测更新
                BusinessAccount.getNewVersion(getActivity(), mHandler);
                break;
            case R.id.tv_ecard_consult: // 咨询回复
                GotoUtil.gotoActivity(getActivity(), EcardConsultActivity.class);
                break;
            case R.id.tv_guanzhu: //关注
                if (!Utils.isLogin(getActivity()))
                    Utils.notLoginGoto(getActivity());
                else {
                    callJsMethod("setItem", new String[]{"logged-person-id", ""});
                    GotoUtil.gotoActivity(getActivity(), MyConcernActivity.class);
                }
                break;
            case R.id.tv_fensi: //粉丝
                if (!Utils.isLogin(getActivity()))
                    Utils.notLoginGoto(getActivity());
                else {
                    GotoUtil.gotoActivity(getActivity(), MyFansActivity.class);
                }
                break;
            case R.id.tv_huozan: //获赞
                break;
            case R.id.tv_zhuanjia_lv:
                GotoUtil.gotoActivity(getActivity(), UpdateExpertActivity.class);
                break;
            case R.id.tv_video_manage://视频管理
                if (!Utils.isLogin(getActivity()))
                    Utils.notLoginGoto(getActivity());
                else {
                    GotoUtil.gotoActivity(getActivity(), MyWorkManageActivity.class);
                }
                break;
            case R.id.tv_buy_video://我购买的视频
                if (!Utils.isLogin(getActivity()))
                    Utils.notLoginGoto(getActivity());
                else {
                    GotoUtil.gotoActivity(getActivity(), MyPurchaseListActivity.class);
                }
                break;
            case R.id.tv_video_zan://我的点赞视频
                if (!Utils.isLogin(getActivity()))
                    Utils.notLoginGoto(getActivity());
                else {
                    GotoUtil.gotoActivity(getActivity(), MyPraiseListActivity.class);
                }
                break;
            case R.id.tv_video_pinglun://视频评论
                if (!Utils.isLogin(getActivity()))
                    Utils.notLoginGoto(getActivity());
                else {
                    GotoUtil.gotoActivity(getActivity(), MyCommentActivity.class);
                }
                break;
            case R.id.tv_my_train:
                //我的培训
                GotoUtil.gotoActivity(getActivity(), MyDemandListActivity.class);
                break;
            case R.id.tv_train_baojia:
                //我的报价
                GotoUtil.gotoActivity(getActivity(), MyQuoteListActivity.class);
                break;
            case R.id.tv_train_case:
                //成功案例
                GotoUtil.gotoActivity(getActivity(), TrainMyCaseActivity.class);
                break;
        }
    }



    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
//        if (requestCode == LOGIN_CODE || requestCode == ACCOUNT_MANAGER_CODE) {
//            if (data != null && data.hasExtra("pointVOList")) {
//                List<PointVO> pointVOList = (List<PointVO>) data.getSerializableExtra("pointVOList");
//                if (pointVOList != null && pointVOList.size() > 0) {
//                    for (int i = 0; i < pointVOList.size(); i++) {
//                        final Dialog dialog = new Dialog(getActivity(), R.style.NoBackGroundDialog);
//                        View v = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_nb, null);
//                        TextView tvNumber = (TextView) v.findViewById(R.id.dialog_tv_nb_number);
//                        TextView tvInfo = (TextView) v.findViewById(R.id.dialog_tv_nb_info);
//                        TextView tvFinish = (TextView) v.findViewById(R.id.dialog_tv_nb_finish);
//                        tvNumber.setText(MessageFormat.format("农币+{0}", pointVOList.get(i).getPointValue()));
//                        tvInfo.setText(pointVOList.get(i).getRemark());
//                        tvFinish.setOnClickListener(new View.OnClickListener() {
//                            @Override
//                            public void onClick(View v) {
//                                dialog.dismiss();
//                            }
//                        });
//                        dialog.setCancelable(false);
//                        dialog.setContentView(v);
//                        dialog.show();
//                    }
//
//                }
//            }
//        }
    }

    @Override
    public void onResume() {
        super.onResume();
        showByLogin();
    }

    @Override
    public void addListener() {

    }

    @Override
    public void rightOnClick() {

    }

    @Override
    public boolean handleMessage(Message msg) {
        if (msg.what == MSG_ACTION_CALLBACK) {
            switch (msg.arg1) {
                case 1: { // 成功提示, successful notification
                    showToast(getString(R.string.ssdk_oks_share_completed));
                    LogUtils.e("------------------分享成功------------------");
                }
                break;
                case 2: { // 失败提示, fail notification
                    String expName = msg.obj.getClass().getSimpleName();
                    if ("WechatClientNotExistException".equals(expName)
                            || "WechatTimelineNotSupportedException".equals(expName)) {
                        showToast(getString(R.string.wechat_client_inavailable));
                    } else if ("GooglePlusClientNotExistException".equals(expName)) {
                        showToast(getString(R.string.google_plus_client_inavailable));
                    } else if ("QQClientNotExistException".equals(expName)) {
                        showToast(getString(R.string.qq_client_inavailable));
                    } else {
                        showToast(getString(R.string.ssdk_oks_share_failed));
                        LogUtils.e("------------------分享失败------------------");
                    }
                }
                break;
                case 3: { // 取消提示, cancel notification
                    showToast(getString(R.string.ssdk_oks_share_canceled));
                    LogUtils.e("------------------取消分享------------------");
                }
                break;
            }
        }
        return false;
    }



    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        ButterKnife.bind(this, rootView);
        return rootView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }


}